package com.lagou.dubbo.web.homework2;

import com.lagou.api.HelloService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class TP90$99Main {
    public static void main(String[] args) {
        ScheduledExecutorService executor = Executors.newScheduledThreadPool(10);

        ClassPathXmlApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("classpath:dubbo-consumer.xml");
        applicationContext.start();

        HelloService helloService = applicationContext.getBean("helloService", HelloService.class);

        /**
         * 每30ms调用一次, 线程池10个线程
         * 满足每分钟2000次, 即每秒34次
         */
        //helloService.fn1("hello1");
        executor.scheduleAtFixedRate(() -> {
            helloService.fn1("hello1");
            helloService.fn2("hello2");
            helloService.fn3("hello3");
        }, 0, 30, TimeUnit.MILLISECONDS);

    }
}
